Sample program for Reinforcement Learning with OpenAI Gym and Keras-rl2

Parameters

Import libraries

=== Scripts to show movement without training ===

Functions to make animation

Random movement

Save (into gif) and show the movement

=== Scripts to show movement with training ===

Import libraries

Class to get animation data during training (learning)

Reinforcement learning using DQN

Import libraries

Parameters

Build a very simple model for reinforcement learning

Definition for the Agent by DQN

Execute training (learning)

Save the final weights

Show the history of rewards during the training

Finally, evaluate the model

Show the animation for test